/*!
 * # 参数列表实体类:
 *  Create - 创建通知消息
 * 
 * # 描述:
 *  创建一条新的通知消息。
 * 
 * Copyright (c), 上海沃恩信息科技有限公司.
 * All rights reserved.
 * Licensed under BSD (https://www.pittypat.work/bsd.html).
 */

using Pittypat;

namespace Waln.Notifying.Service.Args
{
    /// <summary>
    /// 功能 创建通知消息 的参数列表。
    /// </summary>
    [global::Pittypat.Function(Transaction = true)]
    public sealed class Create : global::Pittypat.FunctionArgs
    {
        #region 构造函数

        /// <summary>
        /// 初始化 Create 类的一个新实例。
        /// </summary>
        public Create()
        {
            // 发送用户的 Id
            this.SenderId = null;
            // 接收用户 Id 的列表
            this.Receivers = null;
            // 紧急程度
            this.Urgency = null;
            // 分组
            this.Group = null;
            // 通知标题
            this.Title = null;
            // 通知消息摘要
            this.Summary = null;
            // 通知正文内容
            this.Body = null;
            // 正文类型代码
            this.BodyType = null;
            // 目标功能路径
            this.FuncUrl = null;
            // 引用数据的类型
            this.RefDataType = null;
            // 引用数据键值
            this.RefDataKey = null;
            // 附件文件名称
            this.AttachmentName = null;
            // 附件 MIME 类型
            this.AttachmentMime = null;
            // 附件文件的大小
            this.AttachmentSize = null;
            // 文件路径
            this.AttachmentUrl = null;
            // 上传人的 Id
            this.AttachmentUploaderId = null;
            // 上传时间
            this.AttachmentUploadTime = null;
            // 通知消息
            this.Notification = null;
            // 附件文件
            this.Attachment = null;
        }

        #endregion

        #region 属性

        /// <summary>
        /// 获取或者设置发送用户的 Id。
        /// </summary>
        /// <remarks>
        /// 发送消息的用户的 Id，如果是系统消息，则为 null。
        /// </remarks>
        [global::Pittypat.Parameter(0)]
        public @uuid? SenderId { get; set; }

        /// <summary>
        /// 获取或者设置接收用户 Id 的列表。
        /// </summary>
        /// <remarks>
        /// 接收消息的用户的 Id 的列表，多个之间使用 ',' 分隔。
        /// </remarks>
        [global::Pittypat.Parameter(1, MaxLength = 20000)]
        public @string? Receivers { get; set; }

        /// <summary>
        /// 获取或者设置紧急程度。
        /// </summary>
        /// <remarks>
        /// 通知的紧急程度代码：1-常规，2-紧急，4-特急。默认为常规（1）。
        /// </remarks>
        [global::Pittypat.Parameter(2)]
        public @int8? Urgency { get; set; }

        /// <summary>
        /// 获取或者设置分组。
        /// </summary>
        /// <remarks>
        /// 通知隶属的分组。
        /// </remarks>
        [global::Pittypat.Parameter(3, MaxLength = 30)]
        public @string? Group { get; set; }

        /// <summary>
        /// 获取或者设置通知标题。
        /// </summary>
        /// <remarks>
        /// 通知的标题。
        /// </remarks>
        [global::Pittypat.Parameter(4, MaxLength = 50)]
        public @string? Title { get; set; }

        /// <summary>
        /// 获取或者设置通知消息摘要。
        /// </summary>
        /// <remarks>
        /// 对通知消息正文的摘要信息。
        /// </remarks>
        [global::Pittypat.Parameter(5, MaxLength = 200)]
        public @string? Summary { get; set; }

        /// <summary>
        /// 获取或者设置通知正文内容。
        /// </summary>
        /// <remarks>
        /// 通知的完整正文内容。
        /// </remarks>
        [global::Pittypat.Parameter(6, MaxLength = 200000)]
        public @string? Body { get; set; }

        /// <summary>
        /// 获取或者设置正文类型代码。
        /// </summary>
        /// <remarks>
        /// 消息正文类型代码：1-纯文本，2-HTML。
        /// </remarks>
        [global::Pittypat.Parameter(7)]
        public @int8? BodyType { get; set; }

        /// <summary>
        /// 获取或者设置目标功能路径。
        /// </summary>
        /// <remarks>
        /// 点击消息时要进入的路径。
        /// </remarks>
        [global::Pittypat.Parameter(8, MaxLength = 300)]
        public @string? FuncUrl { get; set; }

        /// <summary>
        /// 获取或者设置引用数据的类型。
        /// </summary>
        /// <remarks>
        /// 如果此消息来自某业务功能，则可能引用某业务数据，此属性定义业务数据的类型。
        /// </remarks>
        [global::Pittypat.Parameter(9, MaxLength = 64)]
        public @string? RefDataType { get; set; }

        /// <summary>
        /// 获取或者设置引用数据键值。
        /// </summary>
        /// <remarks>
        /// 消息引用数据的键值。
        /// </remarks>
        [global::Pittypat.Parameter(10, MaxLength = 50)]
        public @string? RefDataKey { get; set; }

        /// <summary>
        /// 获取或者设置附件文件名称。
        /// </summary>
        /// <remarks>
        /// 附件文件的名称，包含扩展名称。
        /// </remarks>
        [global::Pittypat.Parameter(11, MaxLength = 100)]
        public @string? AttachmentName { get; set; }

        /// <summary>
        /// 获取或者设置附件 MIME 类型。
        /// </summary>
        /// <remarks>
        /// 附件文件的 MIME 类型。
        /// </remarks>
        [global::Pittypat.Parameter(12, MaxLength = 100)]
        public @string? AttachmentMime { get; set; }

        /// <summary>
        /// 获取或者设置附件文件的大小。
        /// </summary>
        /// <remarks>
        /// 附件文件的大小，单位：字节。
        /// </remarks>
        [global::Pittypat.Parameter(13)]
        public @int64? AttachmentSize { get; set; }

        /// <summary>
        /// 获取或者设置文件路径。
        /// </summary>
        /// <remarks>
        /// 附件文件的虚拟路径。
        /// </remarks>
        [global::Pittypat.Parameter(14, MaxLength = 300)]
        public @string? AttachmentUrl { get; set; }

        /// <summary>
        /// 获取或者设置上传人的 Id。
        /// </summary>
        /// <remarks>
        /// 上传了当前附件文件的用户的 Id。
        /// </remarks>
        [global::Pittypat.Parameter(15)]
        public @uuid? AttachmentUploaderId { get; set; }

        /// <summary>
        /// 获取或者设置上传时间。
        /// </summary>
        /// <remarks>
        /// 上传当前附件文件的时间。
        /// </remarks>
        [global::Pittypat.Parameter(16)]
        public @datetime? AttachmentUploadTime { get; set; }

        /// <summary>
        /// 获取或者设置通知消息。
        /// </summary>
        /// <remarks>
        /// 新创建的通知消息。
        /// </remarks>
        [global::Pittypat.Parameter(17, Direction = global::Pittypat.ParameterDirection.Out)]
        public global::Pittypat.DataList<global::Waln.Notifying.Service.Data.Notification> Notification { get; set; }

        /// <summary>
        /// 获取或者设置附件文件。
        /// </summary>
        /// <remarks>
        /// 新创建的附件文件。
        /// </remarks>
        [global::Pittypat.Parameter(18, Direction = global::Pittypat.ParameterDirection.Out)]
        public global::Waln.Notifying.Service.Data.Attachment Attachment { get; set; }

        /// <summary>
        /// 获取或者设置指定名称的参数值。
        /// </summary>
        /// <param name="name">参数名称，不区分大小写。</param>
        /// <returns>目标名称的参数值。如果参数不存在，则返回 null。</returns>
        /// <exception cref="global::System.ArgumentException">设置参数值时发现参数不存在。</exception>
        public override object this[string name]
        {
            get
            {
                if (string.IsNullOrEmpty(name))
                {
                    return null;
                }

                switch (name.ToLower())
                {
                    case "senderid":
                        return this.SenderId;
                    case "receivers":
                        return this.Receivers;
                    case "urgency":
                        return this.Urgency;
                    case "group":
                        return this.Group;
                    case "title":
                        return this.Title;
                    case "summary":
                        return this.Summary;
                    case "body":
                        return this.Body;
                    case "bodytype":
                        return this.BodyType;
                    case "funcurl":
                        return this.FuncUrl;
                    case "refdatatype":
                        return this.RefDataType;
                    case "refdatakey":
                        return this.RefDataKey;
                    case "attachmentname":
                        return this.AttachmentName;
                    case "attachmentmime":
                        return this.AttachmentMime;
                    case "attachmentsize":
                        return this.AttachmentSize;
                    case "attachmenturl":
                        return this.AttachmentUrl;
                    case "attachmentuploaderid":
                        return this.AttachmentUploaderId;
                    case "attachmentuploadtime":
                        return this.AttachmentUploadTime;
                    case "notification":
                        return this.Notification;
                    case "attachment":
                        return this.Attachment;
                    default:
                        return null;
                }
            }
            set
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw new global::System.ArgumentException("没有提供有效的参数名称。", "name");
                }

                switch (name.ToLower())
                {
                    case "senderid":
                        this.SenderId = (@uuid?)value;
                        break;
                    case "receivers":
                        this.Receivers = (@string?)value;
                        break;
                    case "urgency":
                        this.Urgency = (@int8?)value;
                        break;
                    case "group":
                        this.Group = (@string?)value;
                        break;
                    case "title":
                        this.Title = (@string?)value;
                        break;
                    case "summary":
                        this.Summary = (@string?)value;
                        break;
                    case "body":
                        this.Body = (@string?)value;
                        break;
                    case "bodytype":
                        this.BodyType = (@int8?)value;
                        break;
                    case "funcurl":
                        this.FuncUrl = (@string?)value;
                        break;
                    case "refdatatype":
                        this.RefDataType = (@string?)value;
                        break;
                    case "refdatakey":
                        this.RefDataKey = (@string?)value;
                        break;
                    case "attachmentname":
                        this.AttachmentName = (@string?)value;
                        break;
                    case "attachmentmime":
                        this.AttachmentMime = (@string?)value;
                        break;
                    case "attachmentsize":
                        this.AttachmentSize = (@int64?)value;
                        break;
                    case "attachmenturl":
                        this.AttachmentUrl = (@string?)value;
                        break;
                    case "attachmentuploaderid":
                        this.AttachmentUploaderId = (@uuid?)value;
                        break;
                    case "attachmentuploadtime":
                        this.AttachmentUploadTime = (@datetime?)value;
                        break;
                    case "notification":
                        this.Notification = (global::Pittypat.DataList<global::Waln.Notifying.Service.Data.Notification>)value;
                        break;
                    case "attachment":
                        this.Attachment = (global::Waln.Notifying.Service.Data.Attachment)value;
                        break;
                    default:
                        throw new global::System.ArgumentException(name + " 不是 " + this.GetType().Name + " 的有效参数属性名称。", "name");
                }
            }
        }

        #endregion

        #region 方法

        /// <summary>
        /// 将当前对象作为 JSON 字符串写入指定的文本流。
        /// </summary>
        /// <param name="writer">目标文本流。</param>
        /// <exception cref="global::System.ArgumentNullException">writer 是 null。</exception>
        public override void Write(global::System.IO.TextWriter writer)
        {
            if (writer == null)
            {
                throw new global::System.ArgumentNullException("writer");
            }

            writer.Write('{');

            // 发送用户的 Id
            writer.Write("\"senderId\":");
            this.SenderId.Write(writer);
            writer.Write(',');

            // 接收用户 Id 的列表
            writer.Write("\"receivers\":");
            this.Receivers.Write(writer);
            writer.Write(',');

            // 紧急程度
            writer.Write("\"urgency\":");
            this.Urgency.Write(writer);
            writer.Write(',');

            // 分组
            writer.Write("\"group\":");
            this.Group.Write(writer);
            writer.Write(',');

            // 通知标题
            writer.Write("\"title\":");
            this.Title.Write(writer);
            writer.Write(',');

            // 通知消息摘要
            writer.Write("\"summary\":");
            this.Summary.Write(writer);
            writer.Write(',');

            // 通知正文内容
            writer.Write("\"body\":");
            this.Body.Write(writer);
            writer.Write(',');

            // 正文类型代码
            writer.Write("\"bodyType\":");
            this.BodyType.Write(writer);
            writer.Write(',');

            // 目标功能路径
            writer.Write("\"funcUrl\":");
            this.FuncUrl.Write(writer);
            writer.Write(',');

            // 引用数据的类型
            writer.Write("\"refDataType\":");
            this.RefDataType.Write(writer);
            writer.Write(',');

            // 引用数据键值
            writer.Write("\"refDataKey\":");
            this.RefDataKey.Write(writer);
            writer.Write(',');

            // 附件文件名称
            writer.Write("\"attachmentName\":");
            this.AttachmentName.Write(writer);
            writer.Write(',');

            // 附件 MIME 类型
            writer.Write("\"attachmentMime\":");
            this.AttachmentMime.Write(writer);
            writer.Write(',');

            // 附件文件的大小
            writer.Write("\"attachmentSize\":");
            this.AttachmentSize.Write(writer);
            writer.Write(',');

            // 文件路径
            writer.Write("\"attachmentUrl\":");
            this.AttachmentUrl.Write(writer);
            writer.Write(',');

            // 上传人的 Id
            writer.Write("\"attachmentUploaderId\":");
            this.AttachmentUploaderId.Write(writer);
            writer.Write(',');

            // 上传时间
            writer.Write("\"attachmentUploadTime\":");
            this.AttachmentUploadTime.Write(writer);
            writer.Write(',');

            // 通知消息
            writer.Write("\"notification\":");
            if (this.Notification == null)
            {
                writer.Write("null");
            }
            else
            {
                this.Notification.Write(writer);
            }
            writer.Write(',');

            // 附件文件
            writer.Write("\"attachment\":");
            if (this.Attachment == null)
            {
                writer.Write("null");
            }
            else
            {
                this.Attachment.Write(writer);
            }

            writer.Write('}');
        }

        #endregion
    }
}
